package com.wyzz.hr.bo.impl;

import com.wyzz.hr.action.SalaryPaidConverge;
import com.wyzz.hr.base.BaseAction;
import com.wyzz.hr.base.Constants;
import com.wyzz.hr.base.Status;
import com.wyzz.hr.bo.IEmailsendBO;
import com.wyzz.hr.bo.IEmpBenefitBo;
import com.wyzz.hr.bo.IEmpBenefitPlanBo;
import com.wyzz.hr.bo.IEmpSalaryAcctitemsBo;
import com.wyzz.hr.bo.IEmpsalaryperiodBo;
import com.wyzz.hr.bo.ISalaryPaidBo;
import com.wyzz.hr.dao.ISalaryPaidDAO;
import com.wyzz.hr.pojo.Department;
import com.wyzz.hr.pojo.Emailsend;
import com.wyzz.hr.pojo.Empbenefitplan;
import com.wyzz.hr.pojo.Employee;
import com.wyzz.hr.pojo.Empsalaryacctitems;
import com.wyzz.hr.pojo.Empsalaryconfig;
import com.wyzz.hr.pojo.Empsalarydatadef;
import com.wyzz.hr.pojo.Empsalarypay;
import com.wyzz.hr.pojo.Empsalaryperiod;
import com.wyzz.hr.spring.SpringBeanFactory;
import com.wyzz.hr.util.DatabaseSysConfigManager;
import com.wyzz.hr.util.DateUtil;
import com.wyzz.hr.util.MyTools;
import com.wyzz.hr.util.Pager;
import com.wyzz.hr.util.SysConfigManager;
import com.wyzz.hr.util.impl.PropertiesFileConfigManager;

import java.io.PrintStream;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.*;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang.StringUtils;
import org.hibernate.FetchMode;
import org.hibernate.Hibernate;
import org.hibernate.criterion.*;

public class SalaryPaidBoImpl implements ISalaryPaidBo, Status, Constants {

	public SalaryPaidBoImpl() {
	}

	public List getObjects(Class clas, String fetch[]) {
		List result = salaryPaidDAO.getObjects(clas, fetch);
		return result;
	}

	public Empsalarypay loadSalaryPay(Object id, String fetch[]) {
		return (Empsalarypay) salaryPaidDAO.loadObject(
				com.wyzz.hr.pojo.Empsalarypay.class, id, fetch, new boolean[0]);
	}

	public boolean saveOrupdateObject(Object obj) {
		try {
			salaryPaidDAO.saveOrupdate(obj);
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

	public boolean saveOrupdate(Collection objs) {
		try {
			salaryPaidDAO.saveOrupdate(objs);
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

	public List findByCriteria(DetachedCriteria dcPay) {
		return salaryPaidDAO.findByCriteria(dcPay);
	}

	public List findPay(DetachedCriteria dcPay, Pager page) {
		if (page == null) {
			BaseAction.addOrders(dcPay, null,
					new String[] { (new StringBuilder()).append("emp.").append(
							Employee.PROP_EMP_DISTINCT_NO).append("-up")
							.toString() });
			return salaryPaidDAO.findByCriteria(dcPay);
		} else {
			BaseAction.addOrders(dcPay, page,
					new String[] { (new StringBuilder()).append("emp.").append(
							Employee.PROP_EMP_DISTINCT_NO).append("-up")
							.toString() });
			page.splitPage(dcPay);
			return salaryPaidDAO.findByCriteria(dcPay, page.getPageSize(), page
					.getCurrentPage());
		}
	}

	public List findPayPaid(DetachedCriteria dcPay, Pager page) {
		List espList = new ArrayList();
		if (page == null) {
			BaseAction.addOrders(dcPay, null,
					new String[] { (new StringBuilder()).append("emp.").append(
							Employee.PROP_EMP_DISTINCT_NO).append("-up")
							.toString() });
			espList = salaryPaidDAO.findByCriteria(dcPay);
		} else {
			BaseAction.addOrders(dcPay, page,
					new String[] { (new StringBuilder()).append("emp.").append(
							Employee.PROP_EMP_DISTINCT_NO).append("-up")
							.toString() });
			page.splitPage(dcPay);
			espList = salaryPaidDAO.findByCriteria(dcPay, page.getPageSize(),
					page.getCurrentPage());
		}
		if (espList == null || espList.size() == 0)
			return null;
		IEmpSalaryAcctitemsBo itemsBo = (IEmpSalaryAcctitemsBo) SpringBeanFactory
				.getBean("empsalaryacctitemsBo");
		itemsBo.setAcctItemsPay(espList);
		for (Iterator i$ = espList.iterator(); i$.hasNext();) {
			Empsalarypay pay = (Empsalarypay) i$.next();
			try {
				pay.decryEMPPaid(pay);
				calSalaryPayforPage(pay, pay.getAcctItems());
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

		return espList;
	}

	public List findPayNoPaid(DetachedCriteria dcPay, DetachedCriteria dcEmp,
			Pager page) {
		BaseAction.addOrders(dcPay, null, new String[] { "emp."
				+ Employee.PROP_EMP_DISTINCT_NO + "-up" });
		List<Empsalarypay> espList = this.salaryPaidDAO.findByCriteria(dcPay);
		List<Employee> result = new ArrayList();
		if ((StringUtils.isNotEmpty(page.getOrder()))
				&& ("esavEsac.esacName".equalsIgnoreCase(page.getOrder()
						.substring(0, page.getOrder().indexOf("-"))))) {
			page.setOrder("");
		}
		List<Employee> empList = searchEmployee(dcEmp, page);
		boolean hasPaid = false;
		for (Employee currEmp : empList) {
			hasPaid = false;
			for (Empsalarypay esp : espList) {
				if ((currEmp != null) && (currEmp.getId() != null)
						&& (currEmp.getId().equals(esp.getEspEmpno().getId()))) {
					hasPaid = true;
					break;
				}
			}
			if (!hasPaid) {
				result.add(currEmp);
			}
		}
		String[] empIds = new String[result.size()];
		int i = 0;
		for (Employee currEmp : result) {
			empIds[i] = currEmp.getId();
			++i;
		}
		if ((empIds == null) || (empIds.length == 0)) {
			page.setTotalPages(1);
			page.setTotalRows(0);
			return result;
		}
		dcEmp.add(Restrictions.in("id", empIds));
		return searchEmployee(dcEmp, page);
	}

	public List searchEmployee(DetachedCriteria dcEmp, Pager page) {
		if (page == null) {
			BaseAction.addOrders(dcEmp, null,
					new String[] { (new StringBuilder()).append(
							Employee.PROP_EMP_DISTINCT_NO).append("-up")
							.toString() });
			return salaryPaidDAO.findByCriteria(dcEmp);
		} else {
			BaseAction.addOrders(dcEmp, page,
					new String[] { (new StringBuilder()).append(
							Employee.PROP_EMP_DISTINCT_NO).append("-up")
							.toString() });
			page.splitPage(dcEmp);
			return salaryPaidDAO.findByCriteria(dcEmp, page.getPageSize(), page
					.getCurrentPage());
		}
	}

	public boolean haveBeneItems(List items) {
		if (items == null || items.size() == 0)
			return false;
		for (Iterator i$ = items.iterator(); i$.hasNext();) {
			Empsalaryacctitems item = (Empsalaryacctitems) i$.next();
			if (item.getEsaiEsdd().getEsddDataType().intValue() >= 10
					&& item.getEsaiEsdd().getEsddDataType().intValue() <= 16)
				return true;
		}

		return false;
	}

	public void addAddtionalEbpToPay(Empsalarypay pay, boolean add0And1) {
		Empbenefitplan plan = pay.getAddBenefitPlan();
		if (plan == null)
			return;
		try {
			Iterator i$ = pay.getAcctItems().iterator();
			do {
				if (!i$.hasNext())
					break;
				Empsalaryacctitems item = (Empsalaryacctitems) i$.next();
				if (item.getEsaiEsdd().getEsddDataType().intValue() >= 10
						&& item.getEsaiEsdd().getEsddDataType().intValue() <= 16
						&& (item.getEsaiDataIsCalc().intValue() != 0
								&& item.getEsaiDataIsCalc().intValue() != 1 || add0And1)) {
					BigDecimal benefitItemBD = new BigDecimal("0.00");
					Object value = PropertyUtils.getProperty(pay,
							(new StringBuilder()).append("espColumn").append(
									item.getEsaiDataSeq()).toString());
					if (value != null)
						benefitItemBD = (BigDecimal) value;
					if (plan != null) {
						Object valueAdd = PropertyUtils.getProperty(plan,
								(new StringBuilder()).append("ebpColumn")
										.append(item.getEsaiDataSeq())
										.toString());
						if (valueAdd != null)
							benefitItemBD = benefitItemBD
									.add((BigDecimal) valueAdd);
					}
					PropertyUtils.setProperty(pay, (new StringBuilder())
							.append("espColumn").append(item.getEsaiDataSeq())
							.toString(), benefitItemBD);
				}
			} while (true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public boolean batchInitPaidSave(String yearmonth, List payList) {
		if (payList == null || payList.size() == 0)
			return false;
		List planList = new ArrayList();
		Empsalarypay pay;
		Empsalaryconfig config;
		for (Iterator i$ = payList.iterator(); i$.hasNext(); pay
				.setEspEmpconfig(new Empsalaryconfig(config.getId()))) {
			pay = (Empsalarypay) i$.next();
			Empbenefitplan plan = pay.getBenefitPlan();
			if (plan != null) {
				plan.encryEMPPlan(plan);
				planList.add(pay.getBenefitPlan());
			}
			pay.encryEMPPaid(pay);
			Employee emp = pay.getEspEmpno();
			config = emp.getConfig();
			pay.setEspEmpno(new Employee(emp.getId()));
		}

		deleteSalaryPaidByDate(yearmonth);
		Empsalaryperiod emppaidperiod = new Empsalaryperiod();
		emppaidperiod.setEspdYearmonth(yearmonth);
		emppaidperiod.setEspdStatus(Integer.valueOf(0));
		saveOrupdateObject(emppaidperiod);
		saveOrupdate(payList);
		if (planList != null && planList.size() > 0)
			saveOrupdate(planList);
		return true;
	}

	public String batchUpdatePay(String yearmonth, List payList) {
		if (payList == null || payList.size() == 0)
			return "";
		List planList = new ArrayList();
		Set empIds = new HashSet();
		empIds.add(((Empsalarypay) payList.get(0)).getEspEmpno().getId());
		StringBuffer strBuf = new StringBuffer("");
		Empsalarypay pay;
		Empsalaryconfig config;
		for (Iterator i$ = payList.iterator(); i$.hasNext(); pay
				.setEspEmpconfig(new Empsalaryconfig(config.getId()))) {
			pay = (Empsalarypay) i$.next();
			Empbenefitplan plan = pay.getBenefitPlan();
			if (plan != null) {
				plan.encryEMPPlan(plan);
				planList.add(plan);
				empIds.add(pay.getEspEmpno().getId());
			}
			pay.encryEMPPaid(pay);
			strBuf.append(pay.getEspEmpno().getEmpName()).append("\u3001");
			Employee emp = pay.getEspEmpno();
			config = emp.getConfig();
			pay.setEspEmpno(new Employee(emp.getId()));
		}

		IEmpBenefitPlanBo ebpBo = (IEmpBenefitPlanBo) SpringBeanFactory
				.getBean("empbenefitplanBo");
		ebpBo.deleteEbpByYm(yearmonth, Integer.valueOf(0), (String[]) empIds
				.toArray(new String[empIds.size()]));
		saveOrupdate(payList);
		if (planList != null && planList.size() > 0)
			saveOrupdate(planList);
		String str = new String("");
		if (strBuf.length() > 0)
			str = (new StringBuilder()).append(str).append(
					strBuf.substring(0, strBuf.length() - 1)).toString();
		return str;
	}

	public boolean batchUpdatePayImport(String yearmonth,
			List<Empsalarypay> payList) {
		if ((payList == null) || (payList.size() == 0))
			return false;
		List planList = new ArrayList();
		Set empIds = new HashSet();
		for (Empsalarypay pay : payList) {
			Employee emp = pay.getEspEmpno();
			Empsalaryconfig config = emp.getConfig();
			pay.setEspEmpno(new Employee(emp.getId()));
			pay.setEspEmpconfig(new Empsalaryconfig(config.getId()));
			Empbenefitplan tempPlan = pay.getBenefitPlan();
			if (tempPlan != null) {
				tempPlan.encryEMPPlan(tempPlan);
				planList.add(tempPlan);
			}
			empIds.add(emp.getId());
			pay.encryEMPPaid(pay);
		}
		IEmpBenefitPlanBo ebpBo = (IEmpBenefitPlanBo) SpringBeanFactory
				.getBean("empbenefitplanBo");
		ebpBo.deleteEbpByYm(yearmonth, Integer.valueOf(0), (String[]) empIds
				.toArray(new String[empIds.size()]));
		saveOrupdate(payList);
		if ((planList != null) && (planList.size() > 0)) {
			saveOrupdate(planList);
		}
		return true;
	}

	public List findNeedApprovePaids(List departs, String yearmonth,
			Empsalaryperiod espd) {
		List result = new ArrayList();
		if (espd == null) {
			result.clear();
			return result;
		}
		String config = DatabaseSysConfigManager.getInstance().getProperty(
				"sys.examin.month.sum");
		Date dateArr[] = ExaminDateUtil.getDateArray(yearmonth, config);
		String yearmonthLastM = DateUtil.yearMonthAdd(yearmonth, -1, 2);
		Date dateArrLastM[] = ExaminDateUtil.getDateArray(yearmonthLastM,
				config);
		Department depart = null;
		for (int i = 0; i < departs.size(); i++) {
			SalaryPaidConverge salaryPaidConverge = new SalaryPaidConverge();
			depart = (Department) departs.get(i);
			salaryPaidConverge.setEmpDepartment(depart.getDepartmentName());
			salaryPaidConverge.setEmpNumber(getMonthEmpNumber(depart, dateArr));
			salaryPaidConverge.setLastMonthEmpNumber(getMonthEmpNumber(depart,
					dateArrLastM));
			salaryPaidConverge.setQuitEmpNumber(getMonthQuitEmpNumber(depart,
					dateArr));
			salaryPaidConverge.setJoinEmpNumber(getMonthJoinEmpNumber(depart,
					dateArr));
			BigDecimal salaryAmount = getMonthSalaryAmount(depart, yearmonth);
			salaryPaidConverge.setSalaryAmount(salaryAmount);
			BigDecimal salaryAmountLastM = getMonthSalaryAmount(depart,
					yearmonthLastM);
			salaryPaidConverge.setLastMonthSalaryAmount(salaryAmountLastM);
			salaryPaidConverge.setSalaryDifference(salaryAmount
					.subtract(salaryAmountLastM));
			result.add(salaryPaidConverge);
		}

		result.add(getTotalSarlayPaidConverge(result));
		return result;
	}

	public boolean deleteSalaryPaid(Empsalarypay salarypaid) {
		try {
			salaryPaidDAO.deleteObject(salarypaid);
			String hql = (new StringBuilder()).append(
					"delete from Empbenefitplan where ebpYearMonth='").append(
					salarypaid.getEspYearmonth()).append("' ").append(
					" and ebpStatus=0 and ebpEmpno.id='").append(
					salarypaid.getEspEmpno().getId()).append("'").toString();
			salaryPaidDAO.exeHql(hql);
			return true;
		} catch (Exception e) {
			System.out.print(e);
		}
		return false;
	}

	private boolean deleteSalaryPaidByDate(String yearmonth) {
		try {
			salaryPaidDAO.exeHql((new StringBuilder()).append(
					"delete from Empsalarypay where espYearmonth = '").append(
					yearmonth).append("'").toString());
			salaryPaidDAO
					.exeHql((new StringBuilder())
							.append(
									"delete from Empbenefitplan where ebpYearMonth = '")
							.append(yearmonth).append("' and ebpStatus = 0")
							.toString());
			salaryPaidDAO.exeHql((new StringBuilder()).append(
					"delete from Empsalaryperiod where espdYearmonth='")
					.append(yearmonth).append("'").toString());
		} catch (Exception e) {
			System.out.print(e);
			return false;
		}
		return true;
	}

	public List processForOutput(List list, List dataDefList) {
		Set versionIdSet = new HashSet();
		HashMap acctitemsMap = new HashMap();
		for (int i = 0; i < list.size(); i++) {
			Empsalarypay esp = (Empsalarypay) list.get(i);
			try {
				calSalaryPayforOutput(esp, dataDefList, versionIdSet,
						acctitemsMap);
			} catch (Exception e) {
				e.printStackTrace();
			}
			list.set(i, esp);
		}

		Collections.sort(list, new Comparator() {

			public int compare(Empsalarypay obj1, Empsalarypay obj2) {
				return obj1.getEspDept().getId().compareTo(
						obj2.getEspDept().getId());
			}

			public int compare(Object x0, Object x1) {
				return compare((Empsalarypay) x0, (Empsalarypay) x1);
			}
		});
		return list;
	}

	public List findMySalaryPaid(DetachedCriteria dc, Pager page) {
		if (page == null) {
			BaseAction.addOrders(dc, null, new String[] { (new StringBuilder())
					.append(Empsalarypay.PROP_ESP_YEARMONTH).append("-down")
					.toString() });
			return salaryPaidDAO.findByCriteria(dc);
		} else {
			BaseAction.addOrders(dc, page, new String[] { (new StringBuilder())
					.append(Empsalarypay.PROP_ESP_YEARMONTH).append("-down")
					.toString() });
			page.splitPage(dc);
			return salaryPaidDAO.findByCriteria(dc, page.getPageSize(), page
					.getCurrentPage());
		}
	}

	public List searchMySalaryPaid(List espList, String startYearMonth,
			String endYearMonth) {
		IEmpSalaryAcctitemsBo itemsBo = (IEmpSalaryAcctitemsBo) SpringBeanFactory
				.getBean("empsalaryacctitemsBo");
		Map acctItemsMap = itemsBo.getAcctItemsByPay(espList);
		IEmpsalaryperiodBo salaryperiod = (IEmpsalaryperiodBo) SpringBeanFactory
				.getBean("empsalaryperiodBO");
		List paidYearMonthList = salaryperiod.getPaidPeriod(new Integer(2),
				startYearMonth, endYearMonth);
		int i = 0;
		do {
			if (i >= espList.size())
				break;
			Empsalarypay esp = (Empsalarypay) espList.get(i);
			if (paidYearMonthList.contains(esp.getEspYearmonth())) {
				i++;
			} else {
				espList.remove(esp);
				continue;
			}
			try {
				esp.decryEMPPaid(esp);
				esp.setYearAndMonth(esp.getEspYearmonth());
				calSalaryPayforPage(esp, (List) acctItemsMap.get(esp
						.getEspEsavId().getId()));
			} catch (Exception e) {
				e.printStackTrace();
			}
		} while (true);
		return espList;
	}

	public String[][] getBeneItemsByPay(String payId) {
		Empsalarypay payOrig = loadSalaryPay(payId, new String[0]);
		Empsalarypay pay = null;
		try {
			pay = (Empsalarypay) payOrig.clone();
		} catch (CloneNotSupportedException e2) {
			e2.printStackTrace();
		}
		pay.decryEMPPaid(pay);
		Employee employee = pay.getEspEmpno();
		IEmpSalaryAcctitemsBo itemsBo = (IEmpSalaryAcctitemsBo) SpringBeanFactory
				.getBean("empsalaryacctitemsBo");
		List<Empsalaryacctitems> esacItems = itemsBo.getItemsByAcctversion(pay
				.getEspEsavId().getId());
		int beneItemsCount = 0;
		List<Empsalaryacctitems> beneItems = new ArrayList();
		for (Empsalaryacctitems item : esacItems) {
			if ((item.getEsaiEsdd() != null)
					&& (item.getEsaiEsdd().getEsddDataType().intValue() >= 10)
					&& (item.getEsaiEsdd().getEsddDataType().intValue() <= 16)) {
				++beneItemsCount;
				beneItems.add(item);
			}
		}

		IEmpBenefitPlanBo ebpBo = (IEmpBenefitPlanBo) SpringBeanFactory
				.getBean("empbenefitplanBo");
		List<Empbenefitplan> ebpList = ebpBo.getEbpList(pay.getEspYearmonth(),
				employee.getId());
		IEmpSalaryAcctitemsBo esaiBo = (IEmpSalaryAcctitemsBo) SpringBeanFactory
				.getBean("empsalaryacctitemsBo");
		esaiBo.setAcctItemsEbp((Empbenefitplan[]) ebpList
				.toArray(new Empbenefitplan[ebpList.size()]));
		String result[][] = new String[beneItemsCount + 1][ebpList.size() + 2];
		result[0][0] = "\u9879\u76EE\u540D\u79F0";
		int rowCount = 1;
		for (Empsalaryacctitems item : beneItems) {
			result[rowCount][0] = item.getEsaiEsdd().getEsddName();
			++rowCount;
		}

		Class ownerClass = Empbenefitplan.class;
		BigDecimal ebpBD = null;
		result[0][1] = "\u6C47\u603B";
		rowCount = 1;
		for (Iterator i$ = beneItems.iterator(); i$.hasNext();) {
			Empsalaryacctitems item = (Empsalaryacctitems) i$.next();
			try {
				result[rowCount][1] = "0.00";
			} catch (Exception e) {
				e.printStackTrace();
			}
			rowCount++;
		}
		int monthColumn = 2;
		for (Empbenefitplan plan : ebpList) {
			plan.decryEMPPlan(plan);
			result[0][monthColumn] = plan.getEbpBelongYearmonth();
			rowCount = 1;
			for (Empsalaryacctitems item : beneItems) {
				try {
					Method ebpMethod = ownerClass.getMethod("getEbpColumn"
							+ item.getEsaiDataSeq(), new Class[0]);
					ebpBD = (BigDecimal) ebpMethod.invoke(plan, new Object[0]);
				} catch (Exception e) {
					e.printStackTrace();
				}
				result[rowCount][monthColumn] = ((ebpBD != null) ? ebpBD
						.toString() : "0.00");
				result[rowCount][1] = ((ebpBD != null) ? new BigDecimal(
						result[rowCount][1]).add(ebpBD).toString()
						: result[rowCount][1]);
				++rowCount;
			}
			++monthColumn;
		}
		return result;
	}

	public Empsalarypay calSalaryPayforPage(Empsalarypay esp, List acctItems)
			throws Exception {
		if (esp == null)
			return null;
		List sumList = new ArrayList();
		for (int i = 0; i <= 20; i++)
			sumList.add(new BigDecimal("0.00"));

		BigDecimal temp = new BigDecimal("0.00");
		BigDecimal temp1 = new BigDecimal("0.00");
		for (int i = 0; i < acctItems.size(); i++) {
			Empsalaryacctitems esai = (Empsalaryacctitems) acctItems.get(i);
			temp = (BigDecimal) sumList.get(esai.getEsaiEsdd()
					.getEsddDataType().intValue());
			temp1 = (BigDecimal) PropertyUtils.getProperty(esp,
					(new StringBuilder()).append("espColumn").append(i + 1)
							.toString());
			sumList.set(esai.getEsaiEsdd().getEsddDataType().intValue(), temp
					.add(temp1));
		}

		esp.setShowColumn1((BigDecimal) sumList.get(1));
		esp.setShowColumn4((BigDecimal) sumList.get(4));
		esp.setShowColumn7((BigDecimal) sumList.get(7));
		esp.setShowColumn8((BigDecimal) sumList.get(8));
		esp.setShowColumn15((BigDecimal) sumList.get(15));
		esp.setShowColumn17((BigDecimal) sumList.get(17));
		esp.setShowColumn18((BigDecimal) sumList.get(18));
		esp.setShowColumn19((BigDecimal) sumList.get(19));
		return esp;
	}

	private Empsalarypay calSalaryPayforOutput(Empsalarypay esp,
			List dataDefList, Set versionIdSet, HashMap acctitemsMap)
			throws Exception {
		if (esp == null)
			return null;
		String versionId = esp.getEspEsavId().getId();
		if (versionIdSet.add(versionId)) {
			IEmpSalaryAcctitemsBo esaitemsBo = (IEmpSalaryAcctitemsBo) SpringBeanFactory
					.getBean("empsalaryacctitemsBo");
			List acctitemsList = esaitemsBo.getItemsByAcctversion(esp
					.getEspEsavId().getId());
			for (int i = 0; i < dataDefList.size(); i++) {
				Empsalarydatadef datadef = (Empsalarydatadef) dataDefList
						.get(i);
				for (int j = 0; j < acctitemsList.size(); j++) {
					Empsalaryacctitems acctitems = (Empsalaryacctitems) acctitemsList
							.get(j);
					if (acctitems.getEsaiEsdd().getEsddId().equals(
							datadef.getEsddId()))
						acctitemsMap.put((new StringBuilder())
								.append(versionId).append(datadef.getEsddId())
								.toString(), acctitems);
				}

			}

		}
		Map outPutList = new HashMap();
		for (int i = 0; i < dataDefList.size(); i++) {
			Empsalarydatadef datadef = (Empsalarydatadef) dataDefList.get(i);
			Empsalaryacctitems acctitems = (Empsalaryacctitems) acctitemsMap
					.get((new StringBuilder()).append(versionId).append(
							datadef.getEsddId()).toString());
			if (acctitems != null) {
				Class ownerClass = esp.getClass();
				Method espMethod = ownerClass.getMethod((new StringBuilder())
						.append("getEspColumn").append(
								acctitems.getEsaiDataSeq()).toString(),
						new Class[0]);
				BigDecimal value = (BigDecimal) espMethod.invoke(esp,
						new Object[0]);
				outPutList.put(datadef.getEsddId(), value);
			} else {
				outPutList.put(datadef.getEsddId(), new BigDecimal(0.0D));
			}
		}

		esp.setOutPutList(outPutList);
		return esp;
	}

	private String calEspEmailContent(Empsalarypay esp, Hashtable itemsTable)
			throws Exception {
		StringBuffer contentHtml = new StringBuffer();
		List itemsList;
		if (itemsTable == null
				|| itemsTable.get(esp.getEspEsavId().getId()) == null) {
			IEmpSalaryAcctitemsBo esaitemsBo = (IEmpSalaryAcctitemsBo) SpringBeanFactory
					.getBean("empsalaryacctitemsBo");
			itemsList = esaitemsBo.getItemsByAcctversion(esp.getEspEsavId()
					.getId());
			itemsTable.put(esp.getEspEsavId().getId(), itemsList);
		} else {
			itemsList = (List) itemsTable.get(esp.getEspEsavId().getId());
		}
		contentHtml.append((new StringBuilder()).append(
				esp.getEspEmpno().getEmpName()).append(
				"\uFF0C\u60A8\u597D\uFF01<br>").toString());
		contentHtml
				.append((new StringBuilder())
						.append(esp.getEspYearmonth().substring(0, 4))
						.append("\u5E74")
						.append(esp.getEspYearmonth().substring(4))
						.append(
								"\u6708\u85AA\u6C34\u53D1\u653E\u4FE1\u606F\uFF0C\u5982\u4E0B\uFF1A<br><br>")
						.toString());
		contentHtml
				.append("<table border='1' width='100%' solidcellpadding=0  cellspacing=0 style='font-size: 10pt'>");
		contentHtml.append("<TBODY>");
		contentHtml.append("<TR>");
		contentHtml
				.append("<TD width='30%' bgcolor=#ECF6FB>\u5458\u5DE5\u59D3\u540D</TD>");
		contentHtml.append((new StringBuilder()).append("<TD width='20%'>")
				.append(esp.getEspEmpno().getEmpName()).append("</TD>")
				.toString());
		contentHtml
				.append("<TD width='30%' bgcolor=#ECF6FB>\u85AA\u6C34\u53D1\u653E\u5E74\u6708</TD>");
		contentHtml.append((new StringBuilder()).append("<TD width='20%'>")
				.append(esp.getEspYearmonth()).append("</TD>").toString());
		contentHtml.append("</TR>");
		Class ownerClass = esp.getClass();
		for (int i = 0; i < itemsList.size(); i++) {
			Empsalaryacctitems acctitems = (Empsalaryacctitems) itemsList
					.get(i);
			String name = acctitems.getEsaiEsdd().getEsddName();
			if (i % 2 == 0)
				contentHtml.append("<TR>");
			contentHtml.append((new StringBuilder()).append(
					"<TD bgcolor=#ECF6FB>").append(name).append("</TD>")
					.toString());
			Method espMethod = ownerClass.getMethod((new StringBuilder())
					.append("getEspColumn").append(acctitems.getEsaiDataSeq())
					.toString(), new Class[0]);
			BigDecimal data = (BigDecimal) espMethod.invoke(esp, new Object[0]);
			contentHtml.append((new StringBuilder()).append("<TD>")
					.append(data).append("</TD>").toString());
			if (i % 2 == 1 || i == itemsList.size() - 1)
				contentHtml.append("</TR>");
		}

		contentHtml.append("</TBODY>");
		contentHtml.append("</TABLE>");
		contentHtml.append("<br>");
		contentHtml.append("<br>");
		SysConfigManager config = PropertiesFileConfigManager.getInstance();
		contentHtml.append(config.getProperty("email.sys.mailSystemName"));
		contentHtml.append("<br>");
		contentHtml.append(config.getProperty("email.sys.mailAdminPhone"));
		contentHtml.append("<br>");
		return contentHtml.toString();
	}

	public Empsalarypay getSalaryByEmpId(String empId, String yearmonth) {
		DetachedCriteria detachedCriteria = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Empsalarypay.class);
		detachedCriteria.createAlias("espEmpno", "espEmpno", 1);
		detachedCriteria.setFetchMode("espEmpconfig", FetchMode.JOIN);
		detachedCriteria.add(Restrictions.eq(Empsalarypay.PROP_ESP_YEARMONTH,
				yearmonth));
		detachedCriteria.add(Restrictions.eq("espEmpno.id", empId));
		detachedCriteria.setProjection(null);
		List result = salaryPaidDAO.findByCriteria(detachedCriteria);
		if (result != null && result.size() > 0)
			return (Empsalarypay) result.get(0);
		else
			return null;
	}

	public Employee getEmployeeByESP(Empsalarypay esp) {
		DetachedCriteria detachedCriteria = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Employee.class);
		detachedCriteria.setFetchMode("config", FetchMode.JOIN);
		detachedCriteria.setFetchMode("config.escJobgrade", FetchMode.JOIN);
		detachedCriteria.setFetchMode("config.escEsavId", FetchMode.JOIN);
		detachedCriteria.setFetchMode("empBenefitType", FetchMode.JOIN);
		detachedCriteria.setFetchMode("benefit", FetchMode.JOIN);
		detachedCriteria.add(Restrictions.eq(Employee.PROP_ID, esp
				.getEspEmpno().getId()));
		List empList = salaryPaidDAO.findByCriteria(detachedCriteria);
		if (empList.size() > 0)
			return (Employee) empList.get(0);
		else
			return null;
	}

	public String checkSalaryPay(String empId, String year, String month,
			String salaryValue, Integer status) throws Exception {
		if (salaryValue == null || salaryValue.length() <= 0)
			return "nullinput";
		Empsalarypay esp = getSalaryByEmpId(empId, (new StringBuilder())
				.append(year).append(month).toString());
		if (esp == null)
			return "noEmpsalarypay";
		String salary[] = salaryValue.split(",");
		List salaryList = new ArrayList();
		for (int i = 0; i < salary.length; i++)
			salaryList.add(salary[i]);

		Employee emp = getEmployeeByESP(esp);
		if (emp == null)
			return "noEmployee";
		Empsalaryconfig config = emp.getConfig();
		config.decryEmpSalaryConf(config);
		IEmpSalaryAcctitemsBo esaiBo = (IEmpSalaryAcctitemsBo) SpringBeanFactory
				.getBean("empsalaryacctitemsBo");
		List acctList = esaiBo.getItemsByAcctversion(config.getEscEsavId()
				.getId());
		StringBuffer errorFields = new StringBuffer();
		if (acctList != null) {
			for (int i = 0; i < acctList.size(); i++) {
				Empsalaryacctitems item = (Empsalaryacctitems) acctList.get(i);
				if (item.getEsaiDataIsCalc().intValue() == 2
						&& status.intValue() == 1
						&& !((String) salaryList.get(i)).equalsIgnoreCase("x")
						&& item.getEsaiEsdd().getEsddDataType().intValue() != 9)
					errorFields.append("A").append(item.getEsaiDataSeq())
							.append("\u3001");
			}

		}
		if (errorFields.length() > 0)
			return errorFields.toString()
					.substring(0, errorFields.length() - 1);
		else
			return "SUCCESS";
	}

	public List getSalaryPaidbyEsav(String esavId) {
		DetachedCriteria detachedCriteria = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Empsalarypay.class);
		detachedCriteria.createAlias("espEmpno", "espEmpno", 1);
		detachedCriteria
				.setFetchMode("espEmpno.empBenefitType", FetchMode.JOIN);
		detachedCriteria.setFetchMode("espEmpno.benefit", FetchMode.JOIN);
		detachedCriteria.setFetchMode(Empsalarypay.PROP_ESP_JOBGRADE,
				FetchMode.JOIN);
		detachedCriteria.add(Restrictions
				.eq((new StringBuilder()).append(Empsalarypay.PROP_ESP_ESAV_ID)
						.append(".id").toString(), esavId));
		List result = salaryPaidDAO.findByCriteria(detachedCriteria);
		return result;
	}

	public Empsalarypay getSalaryPaidbyEspId(String espId) {
		DetachedCriteria detachedCriteria = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Empsalarypay.class);
		detachedCriteria.createAlias("espEmpno", "espEmpno", 1);
		detachedCriteria.setFetchMode("espEmpno.benefit", FetchMode.JOIN);
		detachedCriteria
				.setFetchMode("espEmpno.empBenefitType", FetchMode.JOIN);
		detachedCriteria.setFetchMode(Empsalarypay.PROP_ESP_EMPCONFIG,
				FetchMode.JOIN);
		detachedCriteria.setFetchMode(Empsalarypay.PROP_ESP_JOBGRADE,
				FetchMode.JOIN);
		detachedCriteria.setFetchMode(Empsalarypay.PROP_ESP_ESAV_ID,
				FetchMode.JOIN);
		detachedCriteria.add(Restrictions.eq(Empsalarypay.PROP_ID, espId));
		List result = salaryPaidDAO.findByCriteria(detachedCriteria);
		if (result != null && result.size() > 0)
			return (Empsalarypay) result.get(0);
		else
			return null;
	}

	private int getMonthEmpNumber(Department depart, Date dateArr[]) {
		DetachedCriteria detachedCriteria = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Employee.class);
		detachedCriteria.add(Restrictions.eq("empDeptNo.id", depart.getId()));
		detachedCriteria.add(Restrictions.or(Restrictions
				.sqlRestriction("emp_status=1 and emp_join_date<=?",
						dateArr[1], Hibernate.DATE), Restrictions
				.sqlRestriction("emp_status=0 and emp_terminate_date >=?",
						dateArr[0], Hibernate.DATE)));
		return salaryPaidDAO.findRowCountByCriteria(detachedCriteria);
	}

	private int getMonthQuitEmpNumber(Department depart, Date dateArr[]) {
		DetachedCriteria detachedCriteria = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Employee.class);
		detachedCriteria.add(Restrictions.eq("empDeptNo.id", depart.getId()));
		detachedCriteria.add(Restrictions.eq("empStatus", Integer.valueOf(0)));
		detachedCriteria.add(Restrictions.ge("empTerminateDate", dateArr[0]));
		detachedCriteria.add(Restrictions.le("empTerminateDate", dateArr[1]));
		return salaryPaidDAO.findRowCountByCriteria(detachedCriteria);
	}

	private int getMonthJoinEmpNumber(Department depart, Date dateArr[]) {
		DetachedCriteria detachedCriteria = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Employee.class);
		detachedCriteria.add(Restrictions.eq("empDeptNo.id", depart.getId()));
		detachedCriteria.add(Restrictions.ge("empJoinDate", dateArr[0]));
		detachedCriteria.add(Restrictions.le("empJoinDate", dateArr[1]));
		return salaryPaidDAO.findRowCountByCriteria(detachedCriteria);
	}

	private BigDecimal getMonthSalaryAmount(Department depart, String yearMonth) {
		DetachedCriteria dc = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Empsalarypay.class);
		dc.createAlias("espEmpno", "emp", 1);
		dc.add(Restrictions.eq(Empsalarypay.PROP_ESP_YEARMONTH, yearMonth));
		dc.add(Restrictions.eq("emp.empDeptNo.id", depart.getId()));
		List salaryPay = salaryPaidDAO.findByCriteria(dc);
		BigDecimal salaryAmount = new BigDecimal(0.0D);
		if (salaryPay != null) {
			IEmpSalaryAcctitemsBo itemsBo = (IEmpSalaryAcctitemsBo) SpringBeanFactory
					.getBean("empsalaryacctitemsBo");
			Map acctItemsMap = itemsBo.getAcctItemsByPay(salaryPay);
			for (int j = 0; j < salaryPay.size(); j++) {
				Empsalarypay esp = (Empsalarypay) salaryPay.get(j);
				try {
					esp.decryEMPPaid(esp);
					calSalaryPayforPage(esp, (List) acctItemsMap.get(esp
							.getEspEsavId().getId()));
				} catch (Exception e) {
					e.printStackTrace();
				}
				if (esp.getShowColumn8() != null)
					salaryAmount = salaryAmount.add(esp.getShowColumn8());
			}

		}
		return salaryAmount;
	}

	private SalaryPaidConverge getTotalSarlayPaidConverge(List result) {
		SalaryPaidConverge totalSalaryPaidConverge = new SalaryPaidConverge();
		totalSalaryPaidConverge.setEmpDepartment("\u6240\u6709\u90E8\u95E8");
		int empNumber = 0;
		int lastMonthEmpNumber = 0;
		int quitEmpNumber = 0;
		int joinEmpNumber = 0;
		BigDecimal salaryAmount = new BigDecimal(0.0D);
		BigDecimal lastMonthSalaryAmount = new BigDecimal(0.0D);
		BigDecimal salaryAmountDifference = new BigDecimal(0.0D);
		SalaryPaidConverge salaryPaidConverge = null;
		for (int i = 0; i < result.size(); i++) {
			salaryPaidConverge = (SalaryPaidConverge) result.get(i);
			empNumber += salaryPaidConverge.getEmpNumber();
			lastMonthEmpNumber += salaryPaidConverge.getLastMonthEmpNumber();
			quitEmpNumber += salaryPaidConverge.getQuitEmpNumber();
			joinEmpNumber += salaryPaidConverge.getJoinEmpNumber();
			salaryAmount = salaryAmount.add(salaryPaidConverge
					.getSalaryAmount());
			lastMonthSalaryAmount = lastMonthSalaryAmount
					.add(salaryPaidConverge.getLastMonthSalaryAmount());
			salaryAmountDifference = salaryAmountDifference
					.add(salaryPaidConverge.getSalaryDifference());
		}

		totalSalaryPaidConverge.setEmpNumber(empNumber);
		totalSalaryPaidConverge.setLastMonthEmpNumber(lastMonthEmpNumber);
		totalSalaryPaidConverge.setQuitEmpNumber(quitEmpNumber);
		totalSalaryPaidConverge.setJoinEmpNumber(joinEmpNumber);
		totalSalaryPaidConverge.setSalaryAmount(salaryAmount);
		totalSalaryPaidConverge.setLastMonthSalaryAmount(lastMonthSalaryAmount);
		totalSalaryPaidConverge.setSalaryDifference(salaryAmountDifference);
		return totalSalaryPaidConverge;
	}

	public List getEmailList(List result) {
		List emailList = new ArrayList();
		Hashtable itemsTable = new Hashtable();
		for (int i = 0; i < result.size(); i++) {
			Empsalarypay esp = (Empsalarypay) result.get(i);
			try {
				Emailsend email = new Emailsend();
				email.setEsTo(esp.getEspEmpno().getEmpEmail());
				email.setEsTitle((new StringBuilder()).append(
						esp.getEspYearmonth().substring(0, 4)).append("\u5E74")
						.append(esp.getEspYearmonth().substring(4)).append(
								"\u6708\u85AA\u8D44\u90AE\u4EF6\u53D1\u9001")
						.toString());
				String content = calEspEmailContent(esp, itemsTable);
				email.setEsContent(content);
				email.setEsStatus(Integer.valueOf(0));
				emailList.add(email);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

		IEmailsendBO emailsendBO = (IEmailsendBO) SpringBeanFactory
				.getBean("emailsendBO");
		List errors = emailsendBO.sendEmailsMain(emailList);
		return errors;
	}

	public int hasSalaryPayByAcctVersion(String acctversionId) {
		DetachedCriteria detachedCriteria = DetachedCriteria
				.forClass(Empsalarypay.class);
		detachedCriteria.add(Restrictions.eq("espEsavId.id", acctversionId));
		detachedCriteria.setProjection(Projections.rowCount());
		List list = salaryPaidDAO.findByCriteria(detachedCriteria);
		return ((Integer) list.get(0)).intValue();
	}

	public ISalaryPaidDAO getSalaryPaidDAO() {
		return salaryPaidDAO;
	}

	public void setSalaryPaidDAO(ISalaryPaidDAO salaryPaidDAO) {
		this.salaryPaidDAO = salaryPaidDAO;
	}

	public List getDecriedSalaryPaidForEmailSend(String emps[], String yearMonth) {
		if (emps == null || emps.length == 0)
			return new ArrayList(0);
		DetachedCriteria detachedCriteria = DetachedCriteria
				.forClass(Empsalarypay.class);
		detachedCriteria.createAlias("espEmpno", "emp", 1);
		detachedCriteria.add(Restrictions.eq(Empsalarypay.PROP_ESP_YEARMONTH,
				yearMonth));
		if (emps.length > 0)
			detachedCriteria.add(Restrictions.in("emp.id", emps));
		List result = salaryPaidDAO.findByCriteria(detachedCriteria);
		IEmpSalaryAcctitemsBo itemsBo = (IEmpSalaryAcctitemsBo) SpringBeanFactory
				.getBean("empsalaryacctitemsBo");
		Map acctItemsMap = itemsBo.getAcctItemsByPay(result);
		for (int i = 0; i < result.size(); i++) {
			Empsalarypay esp = (Empsalarypay) result.get(i);
			try {
				esp.decryEMPPaid(esp);
				calSalaryPayforPage(esp, (List) acctItemsMap.get(esp
						.getEspEsavId().getId()));
			} catch (Exception e) {
				e.printStackTrace();
			}
			result.set(i, esp);
		}

		return result;
	}

	public Boolean shuffleSalaryPay(List salaryPayList, Map fromMap,
			List toItems) {
		for (int i = 0; i < salaryPayList.size(); ++i) {
			try {
				Empsalarypay salaryPay = (Empsalarypay) ((Empsalarypay) salaryPayList
						.get(i)).clone();
				Class fromPayClass = salaryPay.getClass();
				Class toPayClass = ((Empsalarypay) salaryPayList.get(i))
						.getClass();
				String empId = salaryPay.getEspEmpno().getId();
				String dataDefId = new String();
				for (int j = 0; j < toItems.size(); ++j) {
					dataDefId = ((Empsalaryacctitems) toItems.get(j))
							.getEsaiEsdd().getEsddId();
					Integer fromPos = (Integer) fromMap.get(dataDefId);
					BigDecimal getValue;
					if (fromPos != null) {
						if (fromPos.intValue() == j)
							continue;
						Method getMethod = fromPayClass.getMethod(
								"getEspColumn" + (fromPos.intValue() + 1),
								new Class[0]);
						getValue = (BigDecimal) getMethod.invoke(salaryPay,
								new Object[0]);
					} else {
						getValue = MyTools.encryDecimal(empId,
								new BigDecimal(0));
					}
					Method setMethod = toPayClass.getMethod("setEspColumn"
							+ (j + 1), new Class[] { BigDecimal.class });
					setMethod.invoke(salaryPayList.get(i),
							new Object[] { getValue });
				}
			} catch (Exception e) {
				e.printStackTrace();
				return Boolean.valueOf(false);
			}
		}
		salarypayReduceSize(salaryPayList);
		return Boolean.valueOf(true);
	}

	private Boolean salarypayReduceSize(List salaryPayList) {
		for (int i = 0; i < salaryPayList.size(); i++)
			try {
				((Empsalarypay) salaryPayList.get(i)).setEspEmpno(new Employee(
						((Empsalarypay) salaryPayList.get(i)).getEspEmpno()
								.getId()));
			} catch (Exception e) {
				e.printStackTrace();
				return Boolean.valueOf(false);
			}

		return Boolean.valueOf(true);
	}

	public boolean isSalaryPayRecordsExist(String empId) {
		DetachedCriteria detachedCriteria = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Empsalarypay.class);
		detachedCriteria.add(Restrictions.eq("espEmpno.id", empId));
		return salaryPaidDAO.findByCriteria(detachedCriteria).size() > 0;
	}

	public List searchEmployeeHasSalaryPay(String yearmonth) {
		DetachedCriteria detachedCriteria = DetachedCriteria
				.forClass(com.wyzz.hr.pojo.Empsalarypay.class);
		detachedCriteria.setFetchMode("espEmpno", FetchMode.JOIN);
		detachedCriteria.add(Restrictions.eq(Empsalarypay.PROP_ESP_YEARMONTH,
				yearmonth));
		return salaryPaidDAO.findByCriteria(detachedCriteria);
	}

	public String getGivenMonthAvgPay(String empId, String yearMonthArr[]) {
		String yearMonthStr = "";
		for (int i = 0; (yearMonthArr != null) && (i < yearMonthArr.length); ++i) {
			yearMonthStr = yearMonthStr + "'" + yearMonthArr[i] + "',";
		}
		yearMonthStr = yearMonthStr.substring(0, yearMonthStr.length() - 1);
		String hql = "from Empsalarypay where espEmpno = '" + empId
				+ "' and espYearmonth in (" + yearMonthStr + ")";
		List<Empsalarypay> espList = this.salaryPaidDAO.exeHqlList(hql);
		IEmpSalaryAcctitemsBo itemsBo = (IEmpSalaryAcctitemsBo) SpringBeanFactory
				.getBean("empsalaryacctitemsBo");
		Map acctItemsMap = itemsBo.getAcctItemsByPay(espList);
		BigDecimal avgPay_b = new BigDecimal(0);
		BigDecimal avgPay = new BigDecimal(0);
		int count = 0;
		List periodList = getPaidPeriod(yearMonthStr);
		for (Empsalarypay pay : espList) {
			try {
				pay.decryEMPPaid(pay);
				calSalaryPayforPage(pay, (List) acctItemsMap.get(pay
						.getEspEsavId().getId()));
				if (periodList.contains(pay.getEspYearmonth())) {
					avgPay_b = avgPay_b.add(pay.getShowColumn8());
					avgPay = avgPay.add(pay.getShowColumn19());
					++count;
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		if (count == 0) {
			return "0.00,0.00";
		}
		avgPay_b = avgPay_b.divide(new BigDecimal(count), 2);
		avgPay = avgPay.divide(new BigDecimal(count), 2);
		return avgPay_b.toString() + "," + avgPay.toString();
	}

	private List getPaidPeriod(String yearMonthStr) {
		List list = new ArrayList();
		String hql = (new StringBuilder()).append(
				"from Empsalaryperiod where espdYearmonth in (").append(
				yearMonthStr).append(") and espdStatus=2").toString();
		List espdList = salaryPaidDAO.exeHqlList(hql);
		Empsalaryperiod period;
		for (Iterator i$ = espdList.iterator(); i$.hasNext(); list.add(period
				.getEspdYearmonth()))
			period = (Empsalaryperiod) i$.next();

		return list;
	}

	public boolean savePayAndInitEbp(Empsalarypay pay) {
		pay.encryEMPPaid(pay);
		salaryPaidDAO.saveOrupdate(pay);
		IEmpBenefitBo empbenefitBo = (IEmpBenefitBo) SpringBeanFactory
				.getBean("empbenefitBo");
		empbenefitBo.deleteBenefitPlan(pay.getEspYearmonth(), Integer
				.valueOf(0), new String[] { pay.getEspEmpno().getId() });
		Empbenefitplan plan = pay.getBenefitPlan();
		if (plan != null) {
			plan.encryEMPPlan(plan);
			salaryPaidDAO.saveOrupdate(plan);
		}
		return true;
	}

	private ISalaryPaidDAO salaryPaidDAO;
}
